package com.industry;

import com.industry.system.dal.redis.SystemCodeCache;
import com.industry.system.dal.redis.SystemUserInfoCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @Author nbZhuozh
 * @Date 2025-04-03  10:18
 **/
@Component
public class ApplicationStarter implements ApplicationListener<ApplicationStartedEvent> {

    @Autowired
    private SystemCodeCache systemCodeCache;

    @Autowired
    private SystemUserInfoCache systemUserInfoCache;

    public void systemPreating() { // 修正方法名拼写
        systemCodeCache.cacheAll();
        systemUserInfoCache.cacheAll();
        // 其他缓存操作
    }

    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        systemPreating(); // 在事件触发时调用
        bizPreating();
        afterPreatingSet();
    }


    public void bizPreating() {
        // 业务预处理
    }

    public void afterPreatingSet() {
        // 后续处理
    }


}
